*******************************************************************************
******************* REPLICATION DO-FILE FOR THE PAPER: ************************
****** THE PARADOX OF POSITIONAL CONVERGENCE: HOW POLITICAL PARTIES USE A *****
************** COMMITMENT STRATEGY TO STAND OUT FROM COMPETITORS ************** 
*********** (PUBLISHED IN JOURNAL OF EUROPEAN PUBLIC POLICY) ******************
*******************************************************************************
*cd "C:\Users\replication" // Change this to the folder on your computer in which you have placed the replication files

global type "twosimple" // This should be changed to "dim" in order to run the robustness test with dimensions

**# PARTYFACTS_ID
copy "https://partyfacts.herokuapp.com/download/external-parties-csv/" "partyfacts-mapping.csv", replace
insheet using "partyfacts-mapping.csv", clear
keep if inlist(dataset_key, "parlgov", "manifesto")
destring dataset_party_id, replace
save "partyfacts.dta", replace

**# COMPARATIVE MANIFESTO PROJECT
** Importing dataset
copy "https://manifesto-project.wzb.eu/down/data/2020b/datasets/MPDataset_MPDS2020b_stata14.dta" "MPDataset_MPDS2020b_stata14.dta", replace // You might have to login on the manifesto project's webpage before you can download the file
use "MPDataset_MPDS2020b_stata14.dta", clear

keep country countryname per* party partyname partyabbrev date total parfam progtype edate
rename (pervote peruncod) (vote per999)
rename (country countryname party per*) (country_num country dataset_party_id share*)
bys country date: egen votetotal = total(vote), missing
keep if votetotal>=50 

reshape long share, i(dataset_party_id date) j(cmp_code) string

** Grouping cmp_code to issues (using the grouping defined by $type)
g type = "$type"
merge m:1 type cmp_code using "cmp.dta", gen(_cmp) keepusing() keep(master match) // keep(master match)

** Adding partyfacts_id 
g dataset_key = "manifesto"

merge m:1 dataset_key dataset_party_id using "partyfacts.dta" , keep(master match) gen(_pfmanifesto) keepusing(partyfacts_id name_english) // keep(match)

g pf_common_id = partyfacts_id
	replace pf_common_id = dataset_party_id if pf_common_id == .
	
** Number of sentences within each issue
g sentences_del = round(total/100*share)
bys pf_common_id date cmp_code: egen sentences_new_del = total(sentences_del), missing // If there is more than one manifesto under the same pf_common_id (combining partyfacts id & manifesto id), I sum their sentences together
bys pf_common_id date cmp_code: egen min_parfam = min(parfam) // If there is more than one manifesto under the same pf_common_id (combining partyfacts id & manifesto id), and they are assigned to different party families, I make them missing
bys pf_common_id date cmp_code: egen max_parfam = max(parfam) // If there is more than one manifesto under the same pf_common_id (combining partyfacts id & manifesto id), and they are assigned to different party families, I make them missing
replace parfam = . if min_parfam!=max_parfam
bys pf_common_id date cmp_code: egen min_progtype = min(progtype) // If there is more than one manifesto under the same pf_common_id (combining partyfacts id & manifesto id), and they are assigned to different party families, I make them missing
bys pf_common_id date cmp_code: egen max_progtype = max(progtype) // If there is more than one manifesto under the same pf_common_id (combining partyfacts id & manifesto id), and they are assigned to different party families, I make them missing
replace progtype = . if min_progtype!=max_progtype

bys pf_common_id date cmp_code (partyname): gen n = _n
bys pf_common_id date cmp_code (partyname): egen max = max(n)
replace partyname = name_english if max > 1 & max <.
keep if n == 1

*Total number of sentences in manifesto
bys pf_common_id date: egen sentences_total = total(sentences_new_del)

*Counting number of sentences within broad issue categories
bys country pf_common_id date issue ideo: egen sentences = total(sentences_new_del), missing
egen tag = tag(country pf_common_id date issue ideo)
keep if tag == 1

*Reshaping to issue level (left/right on the same row)
keep if inlist(ideo, "Left", "Right")
keep country sentences pf_common_id partyname parfam progtype date edate issue sentences_total ideo n max name_english
reshape wide sentences, i(pf_common_id  date issue) j(ideo) string

*Number of parties
bysort country date issue (pf_common_id): g partyissuenumber = _n
bysort country date issue: egen partyissuetotalnumber = max(partyissuenumber)

*Party saliency
g sentences = sentencesLeft + sentencesRight
g SaliencyLog = log((sentences + 1)/sentences_total)
g Saliencyornot = 1 if sentences>0 & sentences<.
	replace Saliencyornot = 0 if sentences==0

*Party position 
g PositionLogWOzero =  log(sentencesRight + 0.5) - log(sentencesLeft + 0.5) // Position (using log-measure; issues that parties do not mention are counted as missing)
	replace PositionLogWOzero = . if sentencesRight == 0 & sentencesLeft == 0 
g PositionLog =  log(sentencesRight + 0.5) - log(sentencesLeft + 0.5) // Position (using log-measure; issues that parties do not mention are counted as 0)
	replace PositionLog = 0 if sentencesRight == 0 & sentencesLeft == 0 
g PositionLogWOzeroAbs =  abs(log(sentencesRight + 0.5) - log(sentencesLeft + 0.5)) // Positional extremity

save "partyissue.dta", replace
use "partyissue.dta", replace

** Generating position similarity variable
*All parties on the same row
keep PositionLogWOzero PositionLog country date issue partyissuenumber partyissuetotalnumber pf_common_id
reshape wide PositionLogWOzero PositionLog pf_common_id, i(country date issue) j(partyissuenumber)
rename (PositionLog* ) (othPositionLog*)

save "countrypartydate.dta", replace

*Distance - combining with party level data
use "partyissue.dta", replace
merge m:1 country date issue using "countrypartydate.dta", keep(match)

*Measuring distance to other parties
foreach var of varlist PositionLogWOzero PositionLog {
	su partyissuenumber
forvalues d = 1/`r(max)' {
g `var'Distance`d' = abs(`var' - oth`var'`d') if partyissuenumber!=`d'

unab varlist : oth`var'? oth`var'??
unab exclude : oth`var'`d'
local varlist : list varlist - exclude

egen `var'MeanRest`d' = rowmean(`varlist')

replace `var'MeanRest = `var'MeanRest`d' if partyissuenumber==`d'

drop `var'MeanRest`d'
}

egen a`var'Distance = rowmean(`var'Distance*) // Average distance to other parties
egen b`var'Distance = rowmin(`var'Distance*) // Distance to nearest neighbour
}

*Measuring distance to other parties - previous election
foreach n in PositionLogWOzero  { // 
bysort pf_common_id issue (date): g La`n'Distance = a`n'Distance[_n-1]
bysort pf_common_id issue (date): g Lb`n'Distance = b`n'Distance[_n-1]
}

rename (aPosition*Distance LaPosition*Distance bPosition*Distance LbPosition*Distance) (Position*Distance LPosition*Distance Position*DistanceCl LPosition*DistanceCl)

save "manifesto.dta", replace


**# PARLGOV
**# - Vote information
copy "https://dataverse.harvard.edu/api/access/datafile/10437092" "view_election.tab", replace // Version: 2024-08-12)
import delimited "view_election.tab", clear encoding(UTF-8) bindquote(strict) 
g election_date_num = date(election_date, "YMD")
	rename (party_id vote_share) (dataset_party_id vote_share_delete)
	keep if election_type=="parliament"
	g dataset_key = "parlgov"
	merge m:1 dataset_key dataset_party_id using "partyfacts.dta", keep(master using match) gen(_pfparlgov) keepusing(partyfacts_id) // keep(match)

	g pf_common_id = partyfacts_id
	replace pf_common_id = dataset_party_id if pf_common_id == .

	bys pf_common_id election_date: egen vote_share = total(vote_share_delete) // If there is more than one party under the same pf_common_id (combining partyfacts id & parlgov id), I sum their vote share

	egen tag = tag(pf_common_id election_date_num)
	keep if tag == 1
	
save "view_election.dta", replace

**# - Main dataset
copy "https://dataverse.harvard.edu/api/access/datafile/10437088" "view_cabinet.tab", replace // Version: 2024-08-12)
import delimited "view_cabinet.tab", clear encoding(UTF-8) // 
	append using "us.dta" // Adding US data (president status) to parlgov dataset 
	rename (country_name party_id) (country dataset_party_id)
	
*Date variables
g election_date_num = date(election_date, "YMD")
g start_date_num = date(start_date, "YMD")
keep if election_date_num>0

save "view_cabinet.dta", replace 

**# - All parties in each country
use "view_cabinet.dta", replace 
egen party_each = tag(country dataset_party_id)
keep if party_each==1
keep country dataset_party_id
save "parties.dta", replace

**# - All elections in each country
use "view_cabinet.dta", replace 
egen election_each = tag(country election_date_num)
keep if election_each==1
keep country election_date_num

*Next election
bys country (election_date_num): g election_date_num_next = election_date_num[_n + 1]
g date_next = year(election_date_num_next) * 100 + month(election_date_num_next)

save "elections.dta", replace

**# - All governments in each country
use "view_cabinet.dta", replace 

egen government_each = tag(country election_date_num start_date_num)
keep if government_each==1
keep country election_date_num start_date_num

*Number of governments within election period
bys country election_date_num (start_date_num): g gov = _n

*Last government before election 
bys country election_date_num: egen gov_last = max(gov)

*Days from previous elections
bys country (election_date_num): g election_date_num_prev = election_date_num[_n - 1] 
g election_date_days_from_prev = election_date_num - election_date_num_prev 

*Saving
save "governments.dta", replace


**# - Merging  parlgov-files
use "governments.dta", replace
merge m:1 country election_date_num using "elections.dta",  nogen
joinby country using "parties.dta"
merge 1:1 country election_date_num start_date dataset_party_id using "view_cabinet.dta", keepusing(cabinet_party election_date dataset_party_id party_name)

*Adding partyfacts_id 
g dataset_key = "parlgov"
merge m:1 dataset_key dataset_party_id using "partyfacts.dta", keep(master using match) gen(_pfparlgov) keepusing(partyfacts_id) // keep(match)
	replace partyfacts_id = 432 if dataset_party_id == 9998 // US: Democratic Party
	replace partyfacts_id = 809 if dataset_party_id == 9999 // US: Republican Party
		
g pf_common_id = partyfacts_id
	replace pf_common_id = dataset_party_id if pf_common_id == .

bys country election_date_num start_date pf_common_id (cabinet_party): g n = _n
keep if n == 1 

*Cabinet party last government before election
g cabinet_party_simple = 0 if inlist(cabinet_party, ., 0)
	replace cabinet_party_simple = 1 if inlist(cabinet_party, 1)
	
*Government status just before the election
g gov_before_election = 1 if gov==gov_last
keep if gov_before_election == 1

*Parliament experience
bys country pf_common_id election_date_num: egen parl_present_times = total(cabinet_party==0 | cabinet_party==1) //The number of government periods in which a party has been present in parliament
g parl_present = 1 if parl_present_times>0 & parl_present_times<. // Whether or not a party has been present in parliament during an election period

egen tag = tag(country election_date_num parl_present pf_common_id)
bys country pf_common_id tag (election_date_num): g parl_experience_delete = _n if tag==1
bys country pf_common_id election_date_num: egen parl_experience = min(parl_experience_delete) // parl_experience = number of election periods a party has been represented (including the specific election_period)
bys country pf_common_id (election_date_num): replace parl_experience = parl_experience[_n-1] if parl_experience == .
	replace parl_experience = 0 if parl_experience == .
	
g new_party = parl_experience==0 // new_party = a party that has never been in parliament 
drop tag

*Vote share
merge m:1 election_date pf_common_id using "view_election.dta", keepusing(vote_share) keep(match master) gen(_view_election)
replace vote_share = 0 if cabinet_party==.


*Saving
save "parlgov.dta", replace

**# POLCOMMIT
copy "https://dataverse.harvard.edu/api/access/datafile/10951688" "polcommit_v2.0.csv", replace
import delimited "polcommit_v2.0.csv", clear encoding(UTF-8) // 

*Adding partyfacts_id 
rename (party countryname) (dataset_party_id country)
g dataset_key="manifesto"
merge m:1 dataset_key dataset_party_id using "partyfacts.dta", keep(master match) gen(_pfpolcommit) keepusing(partyfacts_id) // keep(match)

g pf_common_id = partyfacts_id
	replace pf_common_id = dataset_party_id if pf_common_id == .

*CMP-categories
replace cmp_code = subinstr(cmp_code, ".", "_", .) if cmp_code!="."
replace cmp_code = "000" if inlist(cmp_code, "NA", "0")

g type = "$type"
merge m:1 type cmp_code using "cmp.dta", keepusing(cmprecode) keep(master match) gen(merge1) // Adding adjusted cmp categories to master dataset to correctly merge with issue categories in manifesto data
replace cmp_code = cmprecode // 
merge m:1 type cmp_code using "cmp.dta", keepusing(issue) keep(match master) gen(merge2)

* Each sentence gets the value 1
g one = 1

*Total number of quasi-sentences within each party and within each issue
bys country pf_common_id date: egen p_sentences = total(one)
bys country pf_common_id date issue: egen i_sentences = total(one)

*Total number of commitments within each party and within each issue
bys country pf_common_id date: egen p_commitment = total(commitment==1)
bys country pf_common_id date issue: egen i_commitment = total(commitment==1)

*Total number of commitments (low and high responsibility) using responsibility measure
bys country pf_common_id date: egen p_commitment_high = total(responsibility==2)
bys country pf_common_id date issue: egen i_commitment_high = total(responsibility==2)

bys country pf_common_id date: egen p_commitment_lowhigh = total(responsibility==1 | responsibility==2)
bys country pf_common_id date issue: egen i_commitment_lowhigh = total(responsibility==1 | responsibility==2)

bys country pf_common_id date: egen p_commitment_low = total(responsibility==1)
bys country pf_common_id date issue: egen i_commitment_low = total(responsibility==1)

*Total number of future references 
bys country pf_common_id date: egen p_future = total(future_policy==1)
bys country pf_common_id date issue: egen i_future = total(future_policy==1)

*Share of commitments within each party and within each issue
foreach var in future commitment commitment_high commitment_lowhigh commitment_low {
	g sh_p_`var' = p_`var'/p_sentences*100
	g sh_i_`var' = i_`var'/i_sentences*100
}

egen issue_level = tag(country pf_common_id date issue)
keep if issue_level==1
keep country pf_common_id date issue p_sentences i_sentences sh_p_commitment* p_commitment* sh_i_commitment* i_commitment* p_future i_future sh_i_future sh_p_future

save "polcommit.dta", replace


**# CPDS
copy "https://cpds-data.org/wp-content/uploads/2023/10/cpds_1960-2020_update_2022.zip" "cpds_1960-2020_update_2022.zip", replace
unzipfile "cpds_1960-2020_update_2022.zip", ifilter(`"(.*\.(do|dta)$)"')
*copy "CPDS_1960-2020_Update_2022.dta" "CPDS_1960-2020_Update_2022.dta", replace
*erase "CPDS_1960-2020_Update_2022.dta"
use "CPDS_1960-2020_Update_2022.dta", clear

* Country name
replace country = "United States" if country=="USA"

* Key variable
g parl = 1 if pres==0
	replace parl = 0 if inlist(pres, 1,2,3,4)

* Saving
save "cpds.dta", replace


**# MERGING THE DATASETS
use "manifesto.dta", clear

merge 1:1 country date pf_common_id issue using "polcommit.dta", gen(_polcommit)  // keep(match using)
bys country pf_common_id date: egen minpartyissuenumber = min(partyissuenumber)
replace partyissuenumber = minpartyissuenumber

*Zero commitments on issues on which the party did not mention in the manifesto
bys country pf_common_id date: egen included = total(_polcommit==3)
	replace sh_i_commitment = 0 if sh_i_commitment==. & included!=0
	replace i_commitment = 0 if i_commitment==. & included!=0

*Only merging with one party per election from the parlgov dataset
g date_next = date
g gov_before_election = 1

merge m:1 country date_next pf_common_id gov_before_election using "parlgov.dta", gen(_parlgov)

g year = floor(date / 100)

merge m:1 country year using "cpds.dta", gen(_cpds)

encode issue, g(issue_num)
encode country, g(country_num)

egen party_level = tag(country pf_common_id date_next) if sh_p_commitment!=. 

save "analysis $type.dta", replace

*Party dyads 
use "analysis twosimple.dta", replace

keep if _parlgov!=2 & _cpds!=2
keep country date issue sh_i_commitment pf_common_id partyissuenumber 
reshape wide sh_i_commitment pf_common_id, i(country date issue) j(partyissuenumber)

merge 1:m country date issue using "analysis twosimple.dta", gen(_electionlevel) keep(match master)

keep othPositionLogWOzero? othPositionLogWOzero?? PositionLogWOzero sh_i_commitment* pf_common_id* country date issue 
rename (pf_common_id* sh_i_commitment*) (othpf_common_id* othsh_i_commitment*)
rename (othpf_common_id othsh_i_commitment) (pf_common_id sh_i_commitment)

reshape long othPositionLogWOzero othsh_i_commitment othpf_common_id, i(country date issue pf_common_id) j(partyissuenumber)

drop if othpf_common_id == pf_common_id

replace sh_i_commitment = . if othsh_i_commitment == .
egen mean_sh_i_commitment = rowmean(othsh_i_commitment sh_i_commitment)

g PositionLogWOzeroDistance = abs(PositionLogWOzero - othPositionLogWOzero)

egen rowmin = rowmin(othpf_common_id pf_common_id)
egen rowmax = rowmax(othpf_common_id pf_common_id)
tostring rowmin rowmax, replace 
g dyad = rowmin + "," + rowmax

bys country date issue dyad: g n = _n 
keep if n == 1

save "analysis dyads.dta", replace


**# ANALYSIS
use "analysis twosimple.dta", replace

*Appendix letter and table number 
local a = "D"
local t = 0
local t = `t' + 1

**# MAIN ANALYSIS
* Model 1 - Main effect (including illustration and effect of one standard deviation)
**# - Direct effekt - simple
g esample1 = 0
eststo model1_`t'_1: reg sh_i_commitment c.PositionLogWOzeroDistanceCl i.issue_num
replace esample1=1 if e(sample)==1
tab country_num if e(sample)==1
estadd scalar n_countries = r(r)
estadd local issue_dummies = "Yes"
estadd local year_dummies = "No"
estadd local country_dummies = "No"

su PositionLogWOzeroDistanceCl if esample1==1, detail
margins, at(PositionLogWOzeroDistanceCl=(`r(p10)' `r(p90)'))
matrix results = r(b)
local rlowm = results[1,1]
local rhighm = results[1,2]
di `rlowm'
di `rhighm'
di (`rlowm' - `rhighm')/`rlowm' * 100 // Change in percent

local b = el(e(b), 1,1)
su PositionLogWOzeroDistanceCl if esample1==1, detail
di `r(sd)'*`b' // Change in standard deviation
di "`r(p10)' - `r(p90)'"

**# - Direct effect - advanced 
g esample2 = 0
eststo model1_`t'_2: reg sh_i_commitment c.PositionLogWOzeroDistanceCl i.issue_num i.year i.country_num
replace esample2 = 1 if e(sample)==1

tab country_num if esample2==1
estadd scalar n_countries = r(r)
estadd local issue_dummies = "Yes"
estadd local year_dummies = "Yes"
estadd local country_dummies = "Yes"

local b = el(e(b), 1,1)
su PositionLogWOzeroDistanceCl if esample2==1, detail
di `r(sd)'*`b' // Change in standard deviation
di "`r(p10)' - `r(p90)'"

bys country pf_common_id issue: egen minP = min(PositionLogWOzeroDistanceCl) if esample2==1
bys country pf_common_id issue: egen maxP = max(PositionLogWOzeroDistanceCl) if esample2==1
egen tag = tag(country pf_common_id issue) if e(sample)==1
g range = maxP - minP
su range if tag==1 // Within unit (mean) change
di `r(mean)'*`b' // Effect based on within unit mean change

su PositionLogWOzeroDistanceCl if esample2==1, detail
local rlow: di %5.2f `r(min)'
local rhigh: di %5.2f `r(max)'
di "`rlow'  `rhigh'"
margins, at(PositionLogWOzeroDistanceCl=(`r(min)' (0.2) `r(max)'))
marginsplot, scheme(s1mono) xtitle("Positional distance") ytitle("Predicted share of commitments") title("") note("", size(vsmall)) xscale(range(-0.1 1.5)) recastci(rline) ciopts(lpattern(dash)) recast(line)	yscale(range(4 19)) ylabel(5 "5%" 6 "6%" 7 "7%" 8 "8%" 9 "9%" 10 "10%" 11 "11%" 12 "12%" 13 "13%" 14 "14%" 15 "15%" 16 "16%" 17 "17%" 18 "18%" 19 "19%" 20 "20%", angle(360) grid labsize(small)) addplot(hist PositionLogWOzeroDistanceCl if PositionLogWOzeroDistanceCl<`rhigh',percent yscale(alt axis(2) range(0 (5) 50)) discrete yaxis(2) below gap(10) legend(off)  xscale(range(-0.1 1.5)) xlabel(`rlow' `""No""distance"" ""' 1.0 " " 2.0 " " 3.0 " " 4.0 " " 5.0 " " 6.0 " " 7.0 " " `rhigh' `""Maximum""distance""', labsize(small)) ytitle("Distribution of                                          ""positional distance                                          ", axis(2) ) ylabel(0 "0%" 5 "5%" 10 "10%" 15 "15%" 20 "20%", nogrid axis(2) angle(360) labsize(small)))
	graph export "main effect advanced.png",  width(6000) height(4000) replace
	graph export "main effect advanced.eps", as(eps) replace

save "after analysis.dta", replace

**# - Interaction: Parlament
use "after analysis.dta", replace

eststo model1_`t'_3: reg sh_i_commitment c.PositionLogWOzeroDistanceCl##i.parl i.issue_num i.year
tab country_num if e(sample)==1
estadd scalar n_countries = r(r)
estadd local country_dummies = "No"
estadd local year_dummies = "Yes"
estadd local issue_dummies = "Yes"

margins, dydx(PositionLogWOzeroDistanceCl) at(parl=(0 1))
marginsplot, recast(scatter) legend(off) title("") ///
    xlabel(0(1)1) ylabel(,angle(horizontal)) xlabel(-0.5 " " 0 `""Non-parliamentary""system""' 1 `""Parliamentary""system""' 1.5 " ") ///
    xtitle("") ytitle("Marginal effect of positional distance""on share of commitments") scheme(s1mono) yline(0, lpattern(dash) ) ylabel(-4 -3 -2 -1 0 1)
	graph export "parliamentary marginal.png", replace

**# - Interaction: Government party
use "after analysis.dta", replace

eststo model1_`t'_4: reg sh_i_commitment c.PositionLogWOzeroDistanceCl##i.cabinet_party_simple i.issue_num i.year i.country_num
tab country_num if e(sample)==1
estadd scalar n_countries = r(r)
estadd local country_dummies = "Yes"
estadd local year_dummies = "Yes"
estadd local issue_dummies = "Yes"

margins, dydx(PositionLogWOzeroDistanceCl) at(cabinet_party_simple=(0 1))
marginsplot, recast(scatter) legend(off) title("") xlabel(0(1)1) ylabel(,angle(horizontal)) xlabel(-0.5 " " 0 "Opposition party" 1 "Government party" 1.5 " ") xtitle("") ytitle("Marginal effect of positional distance""on share of commitments") scheme(s1mono) yline(0, lpattern(dash) ) ylabel(-4 -3 -2 -1 0 1)
	graph export "government marginal.png", replace

**# - Interaction: Positional extremity
use "after analysis.dta", replace

eststo model1_`t'_5: reg sh_i_commitment c.PositionLogWOzeroDistanceCl##c.PositionLogWOzeroAbs i.issue_num i.year i.country_num
tab country_num if e(sample)==1
estadd scalar n_countries = r(r)
estadd local country_dummies = "Yes"
estadd local year_dummies = "Yes"
estadd local issue_dummies = "Yes"

su PositionLogWOzeroAbs
margins, dydx(PositionLogWOzeroDistanceCl) at(PositionLogWOzeroAbs=(`r(min)' (1) `r(max)'))
marginsplot, legend(off) title("") xlabel(0(1)7) ylabel(,angle(horizontal))  xtitle("Positional extremity") ytitle("Marginal effect of positional distance""on share of commitments") scheme(s1mono) yline(0, lpattern(dash) ) ylabel(-4 -3 -2 -1 0 1)
	graph export "extremity marginal.png", replace

esttab model1_`t'_1 model1_`t'_2 model1_`t'_3 model1_`t'_4 model1_`t'_5 using "main table.rtf",  replace ///
	label se stats(N r2 n_countries country_dummies year_dummies issue_dummies, labels(Observations R-squared "Number of countries" "Country dummies included" "Year dummies included" "Issue dummies included")) nonotes star(† 0.1 * 0.05 ** 0.01 *** 0.001) addnotes("Notes: †<0.1 *p<0.05, **p<0.01, ***p<0.001. Country dummies (model II, IV, and V), year dummies (model II, III, IV, and V) and issue dummies (all models) are not shown. For the full model including dummy coefficients, see Appendix D.") varwidth(40) cells(b(star fmt(a2)) se(par fmt(a2))) nonumbers mtitles("I" "II" "III" "IV" "V" "VI") collabels(" " "" "" "") interaction(" * ") title("Table 3: The effect of positional distance on share of commitments")  wide drop(*issue_num *country_num *year 0.cabinet_party_simple 0.parl 0.parl#c.PositionLogWOzeroDistanceCl 0.cabinet_party_simple#c.PositionLogWOzeroDistanceCl)	order(PositionLogWOzeroDistanceCl 1.parl 1.parl#c.PositionLogWOzeroDistanceCl 1.cabinet_party_simple 1.cabinet_party_simple#c.PositionLogWOzeroDistanceCl PositionLogWOzeroAbs c.PositionLogWOzeroDistanceCl#c.PositionLogWOzeroAbs) refcat(, label(" ")) varlabels(PositionLogWOzeroDistanceCl "Positional distance" PositionLogWOzeroAbs "Positional extremity" 1.parl "Parliamentary system (ref = presidential, semi-presidential or hybrid system)" 1.parl#c.PositionLogWOzeroDistanceCl "Positional Distance * Parliamentary system (ref = presidential, semi-presidential or hybrid system)" 1.cabinet_party_simple "Government party (ref = opposition party)" 1.cabinet_party_simple#c.PositionLogWOzeroDistanceCl "Positional distance * Government party (ref = opposition party)" c.PositionLogWOzeroDistanceCl#c.PositionLogWOzeroAbs "Positional distance * Positional extremity" _cons "Constant") // 


**# - Full model (incl country and issue dummies)
label define year_level 1946 "-1946" 1947 "-1947" 1948 "-1948" 1949 "-1949" 1950 "-1950" 1951 "-1951" 1952 "-1952" 1953 "-1953" 1954 "-1954" 1955 "-1955" 1956 "-1956" 1957 "-1957" 1958 "-1958" 1959 "-1959" 1960 "-1960" 1961 "-1961" 1962 "-1962" 1963 "-1963" 1964 "-1964" 1965 "-1965" 1966 "-1966" 1967 "-1967" 1968 "-1968" 1969 "-1969" 1970 "-1970" 1971 "-1971" 1972 "-1972" 1973 "-1973" 1974 "-1974" 1975 "-1975" 1976 "-1976" 1977 "-1977" 1978 "-1978" 1979 "-1979" 1980 "-1980" 1981 "-1981" 1982 "-1982" 1983 "-1983" 1984 "-1984" 1985 "-1985" 1986 "-1986" 1987 "-1987" 1988 "-1988" 1989 "-1989" 1990 "-1990" 1991 "-1991" 1992 "-1992" 1993 "-1993" 1994 "-1994" 1995 "-1995" 1996 "-1996" 1997 "-1997" 1998 "-1998" 1999 "-1999" 2000 "-2000" 2001 "-2001" 2002 "-2002" 2003 "-2003" 2004 "-2004" 2005 "-2005" 2006 "-2006" 2007 "-2007" 2008 "-2008" 2009 "-2009" 2010 "-2010" 2011 "-2011" 2012 "-2012" 2013 "-2013" 2014 "-2014" 2015 "-2015" 2016 "-2016" 2017 "-2017" 2018 "-2018" 2019 "-2019" 2020 "-2020"
label values year year_level

esttab model1_`t'_1 model1_`t'_2 model1_`t'_3 model1_`t'_4 model1_`t'_5 using "table `a'`t' - full.rtf",  replace label se stats(N r2 n_countries country_dummies year_dummies issue_dummies, labels(Observations R-squared "Number of countries" "Country dummies included" "Year dummies included" "Issue dummies included")) nonotes star(† 0.1 * 0.05 ** 0.01 *** 0.001) addnotes("Notes: † 0.1 *p<0.05, **p<0.01, ***p<0.001.") varwidth(40) cells(b(star fmt(a2)) se(par fmt(a2))) nonumbers mtitles("I" "II" "III" "IV" "V" "VI") collabels(" " "" "" "") interaction(" * ") title("Table `a'`t': The effect of positional distance on share of commitments - full model")  wide drop(0.cabinet_party_simple 0.parl 0.parl#c.PositionLogWOzeroDistanceCl 0.cabinet_party_simple#c.PositionLogWOzeroDistanceCl) order(PositionLogWOzeroDistanceCl 1.parl 1.parl#c.PositionLogWOzeroDistanceCl 1.cabinet_party_simple 1.cabinet_party_simple#c.PositionLogWOzeroDistanceCl PositionLogWOzeroAbs c.PositionLogWOzeroDistanceCl#c.PositionLogWOzeroAbs) refcat(1.issue_num "Issue dummies" 1946.year "Year dummies" 3.country_num "Country dummies", label(" ")) varlabels(PositionLogWOzeroDistanceCl "Positional distance" 1.parl "Parliamentary system (ref = presidential, semi-presidential or hybrid system)" 1.parl#c.PositionLogWOzeroDistanceCl "Positional Distance * Parliamentary system (ref = presidential, semi-presidential or hybrid system)" 1.cabinet_party_simple "Government party (ref = opposition party)" 1.cabinet_party_simple#c.PositionLogWOzeroDistanceCl "Positional distance * Government party (ref = opposition party)" c.PositionLogWOzeroDistanceCl#c.PositionLogWOzeroAbs "Positional distance * Positional extremity" PositionLogWOzeroAbs "Positional extremity" _cons "Constant")


**# INTERPRETATION OF FINDING
use "after analysis.dta", replace

**# - Standardized measure of positional distance
local t = `t' + 1

summarize PositionLogWOzeroDistanceCl if esample2==1
local sd = r(sd)
gen sc_PositionLogWOzeroDistanceCl = cond(esample2==1,PositionLogWOzeroDistanceCl / (2 * `sd'),.)

eststo model1_`t'_6: reg sh_i_commitment c.sc_PositionLogWOzeroDistanceCl i.issue_num 
tab country_num if e(sample)==1
estadd scalar n_countries = r(r)
estadd local country_dummies = "No"
estadd local year_dummies = "No"
estadd local issue_dummies = "Yes"

eststo model1_`t'_7: reg sh_i_commitment c.sc_PositionLogWOzeroDistanceCl i.issue_num i.year i.country_num
tab country_num if e(sample)==1
estadd scalar n_countries = r(r)
estadd local country_dummies = "Yes"
estadd local year_dummies = "Yes"
estadd local issue_dummies = "Yes"

esttab model1_`t'_6 model1_`t'_7  using "table `a'`t' - interpretation.rtf", replace label se stats(N r2 n_countries country_dummies year_dummies issue_dummies, labels(Observations R-squared "Number of countries" "Country dummies included" "Year dummies included" "Issue dummies included")) nonotes  star(† 0.1 * 0.05 ** 0.01 *** 0.001) addnotes("Notes: †<0.1 *p<0.05, **p<0.01, ***p<0.001. Country dummies (in model II), year dummies (in model II), and issue dummies (in both models) are not shown.") varwidth(40) cells(b(star fmt(a2)) se(par fmt(a2))) nonumbers mtitles("I" "II") collabels(" " "" "" "") interaction(" * ") title("Table `a'`t': Standardized measure of positional distance")  wide drop(*issue_num *year *country_num) order(sc_PositionLogWOzeroDistanceCl year) refcat() varlabels(sc_PositionLogWOzeroDistanceCl "Positional distance (standardized)" _cons "Constant") // 



**# ROBUSTNESS TESTS
**# - Average distance
use "after analysis.dta", replace
local t = `t' + 1

eststo model1_`t'_1: reg sh_i_commitment c.PositionLogWOzeroDistance i.issue_num
tab country_num if e(sample)==1
estadd scalar n_countries = r(r)
estadd local country_dummies = "No"
estadd local year_dummies = "No"
estadd local issue_dummies = "Yes"

eststo model1_`t'_2: reg sh_i_commitment c.PositionLogWOzeroDistance i.issue_num i.year i.country_num
tab country_num if e(sample)==1
estadd scalar n_countries = r(r)
estadd local country_dummies = "Yes"
estadd local year_dummies = "Yes"
estadd local issue_dummies = "Yes"

esttab model1_`t'_1 model1_`t'_2  using "table `a'`t' - average party.rtf", replace label se stats(N r2 n_countries country_dummies year_dummies issue_dummies, labels(Observations R-squared "Number of countries" "Country dummies included" "Year dummies included" "Issue dummies included")) nonotes  star(† 0.1 * 0.05 ** 0.01 *** 0.001) addnotes("Notes: †<0.1 *p<0.05, **p<0.01, ***p<0.001. Country dummies (in model II), year dummies (in model II), and issue dummies (in both models) are not shown.") varwidth(40) cells(b(star fmt(a2)) se(par fmt(a2))) nonumbers mtitles("I" "II") collabels(" " "" "" "") interaction(" * ") title("Table `a'`t': Average distance")  wide drop(*issue_num *year *country_num) order(PositionLogWOzeroDistance year) refcat() varlabels( PositionLogWOzeroDistance "Positional distance (average)" _cons "Constant") // 


su PositionLogWOzeroDistance if e(sample)==1, detail
local rlow: di %5.2f `r(min)'
local rhigh: di %5.2f `r(max)'
di "`rlow'  `rhigh'"
margins, at(PositionLogWOzeroDistance=(`r(min)' (0.2) `r(max)'))
marginsplot, ///
	scheme(s1mono) ///
	xtitle("Positional distance") ytitle("Predicted share of commitments") title("") note("", size(vsmall)) ///
	xscale(range(-0.1 1.5)) recastci(rline) ciopts(lpattern(dash)) recast(line) ///
	yscale(range(4 19)) ylabel(5 "5%" 6 "6%" 7 "7%" 8 "8%" 9 "9%" 10 "10%" 11 "11%" 12 "12%" 13 "13%" 14 "14%" 15 "15%" 16 "16%" 17 "17%" 18 "18%" 19 "19%" 20 "20%", angle(360) grid labsize(small)) ///
	addplot(hist PositionLogWOzeroDistance if PositionLogWOzeroDistance<`rhigh',percent yscale(alt axis(2) range(0 (5) 50)) yaxis(2) below gap(10) legend(off)  xscale(range(-0.1 1.5)) xlabel(`rlow' `""No""distance"" ""' 1.0 " " 2.0 " " 3.0 " " 4.0 " " 5.0 " " 6.0 " " 7.0 " " `rhigh' `""Maximum""distance""', labsize(small)) ytitle("Distribution of                                          ""positional distance                                          ", axis(2) ) ylabel(0 "0%" 5 "5%" 10 "10%" 15 "15%" 20 "20%", nogrid axis(2) angle(360) labsize(small)))
	
graph export "average distance - marginsplot.png", replace

**# - Comparing the effects using different levels of responsibility-taking
use "analysis twosimple.dta", replace

local t = `t' + 1

eststo model1_`t'_1: reg sh_i_commitment_low c.PositionLogWOzeroDistanceCl sh_i_future i.issue_num
tab country_num if e(sample)==1
estadd scalar n_countries = r(r)
estadd local country_dummies = "No"
estadd local year_dummies = "No"
estadd local issue_dummies = "Yes"
eststo model1_`t'_2: reg sh_i_commitment_low c.PositionLogWOzeroDistanceCl sh_i_future i.issue_num i.year i.country_num 
tab country_num if e(sample)==1
estadd scalar n_countries = r(r)
estadd local country_dummies = "Yes"
estadd local year_dummies = "Yes"
estadd local issue_dummies = "Yes"

eststo model1_`t'_3: reg sh_i_commitment_lowhigh c.PositionLogWOzeroDistanceCl sh_i_future i.issue_num
tab country_num if e(sample)==1
estadd scalar n_countries = r(r)
estadd local country_dummies = "No"
estadd local year_dummies = "No"
estadd local issue_dummies = "Yes"
eststo model1_`t'_4: reg sh_i_commitment_lowhigh c.PositionLogWOzeroDistanceCl sh_i_future i.issue_num i.year i.country_num 
tab country_num if e(sample)==1
estadd scalar n_countries = r(r)
estadd local country_dummies = "Yes"
estadd local year_dummies = "Yes"
estadd local issue_dummies = "Yes"

eststo model1_`t'_5: reg sh_i_commitment_high c.PositionLogWOzeroDistanceCl sh_i_future i.issue_num
tab country_num if e(sample)==1
estadd scalar n_countries = r(r)
estadd local country_dummies = "No"
estadd local year_dummies = "No"
estadd local issue_dummies = "Yes"
eststo model1_`t'_6: reg sh_i_commitment_high c.PositionLogWOzeroDistanceCl sh_i_future i.issue_num i.year i.country_num 
tab country_num if e(sample)==1
estadd scalar n_countries = r(r)
estadd local country_dummies = "Yes"
estadd local year_dummies = "Yes"
estadd local issue_dummies = "Yes"


esttab model1_`t'_1 model1_`t'_2 model1_`t'_3 model1_`t'_4 model1_`t'_5 model1_`t'_6 using "table `a'`t' - lowresp.rtf", label se stats(N r2 n_countries country_dummies year_dummies issue_dummies, labels(Observations R-squared "Number of countries" "Country dummies included" "Year dummies included" "Issue dummies included")) nonotes  star(† 0.1 * 0.05 ** 0.01 *** 0.001) addnotes("Notes: †<0.1 *p<0.05, **p<0.01, ***p<0.001. Country dummies (in model II, IV, and VI), year dummies (in model II, IV, and IV), and issue dummies (in all models) are not shown. Model I and II measure DV as share of statements with only low responsibility taking for future policies, Model III and IV measure DV as share of statements with low and high responsibility taking for future policies, and Model V and VI measure DV as share of statements with only high responsibility taking for future policies   ") varwidth(40) cells(b(star fmt(a2)) se(par fmt(a2))) nonumbers mtitles("I" "II" "III" "IV" "V" "VI") collabels("" "" "")  replace  order() title("Table `a'`t'.2: Different dependent variables") refcat(10.parfam "Party family" 13.country "Country" 0.cabinet_party2 "Government status", nolabel) wide drop(*issue_num *year *country_num) varlabels(PositionLogWOzeroDistanceCl "Positional distance" sh_i_future "Share of statements mentioning future policies" _cons "Constant")

**# - Additional control variables (incl. country, party and issue variables from main analysis)
use "analysis twosimple.dta", replace

local t = `t' + 1

eststo model1_`t'_1: reg sh_i_commitment c.PositionLogWOzeroDistanceCl i.parl i.cabinet_party_simple c.PositionLogWOzeroAbs i.issue_num
tab country_num if e(sample)==1
estadd scalar n_countries = r(r)
estadd local country_dummies = "No"
estadd local year_dummies = "No"
estadd local issue_dummies = "Yes"
eststo model1_`t'_2: reg sh_i_commitment c.PositionLogWOzeroDistanceCl i.parl i.cabinet_party_simple c.PositionLogWOzeroAbs i.issue_num i.year i.country_num
tab country_num if e(sample)==1
estadd scalar n_countries = r(r)
estadd local country_dummies = "Yes"
estadd local year_dummies = "Yes"
estadd local issue_dummies = "Yes"

eststo model1_`t'_3: reg sh_i_commitment c.PositionLogWOzeroDistanceCl PositionLogWOzero SaliencyLog i.new_party vote_share i.parfam election_date_days_from_prev i.issue_num 
tab country_num if e(sample)==1
estadd scalar n_countries = r(r)
estadd local country_dummies = "No"
estadd local year_dummies = "No"
estadd local issue_dummies = "Yes"
eststo model1_`t'_4: reg sh_i_commitment c.PositionLogWOzeroDistanceCl PositionLogWOzeroAbs SaliencyLog i.new_party vote_share i.parfam election_date_days_from_prev i.issue_num i.year i.country_num
tab country_num if e(sample)==1
estadd scalar n_countries = r(r)
estadd local country_dummies = "Yes"
estadd local year_dummies = "Yes"
estadd local issue_dummies = "Yes"

esttab model1_`t'_1 model1_`t'_2  model1_`t'_3 model1_`t'_4 using "table `a'`t' - extra controls.rtf", replace label se stats(N r2 n_countries country_dummies year_dummies issue_dummies, labels(Observations R-squared "Number of countries" "Country dummies included" "Year dummies included" "Issue dummies included")) nonotes  star(† 0.1 * 0.05 ** 0.01 *** 0.001) addnotes("Notes: †<0.1 *p<0.05, **p<0.01, ***p<0.001. Country dummies (in model II and IV), year dummies (in model II and IV), and issue dummies (in all models) are not shown.") varwidth(40) cells(b(star fmt(a2)) se(par fmt(a2))) nonumbers mtitles("I" "II" "III" "IV") collabels(" " "" "" "") interaction(" * ") title("Table `a'`t': Additional control variables") wide  ///
	drop(*issue_num *year *country_num 0.cabinet_party_simple 0.parl 0.new_party) ///
	order(PositionLogWOzeroDistanceCl 1.parl 1.cabinet_party_simple PositionLogWOzeroAbs) ///
	refcat(10.parfam "Party family", label(" ")) ///
	varlabels(PositionLogWOzeroDistanceCl "Positional distance" PositionLogWOzeroAbs "Positional extremity" PositionLogWOzero "Position" SaliencyLog "Saliency" 1.parl "Parliamentary system (ref = presidential, semi-presidential or hybrid system)" 1.cabinet_party_simple "Government party (ref = opposition party)" 1.new_party "New party (ref = old party)" vote_share "Vote share (previous election)" 10.parfam "- Ecological parties" 20.parfam "- Socialist or other left parties" 30.parfam "- Social democratic parties" 40.parfam "- Liberal parties" 50.parfam "- Christian democratic parties" 60.parfam "- Conservative parties" 70.parfam "- Nationalist parties" 80.parfam "- Agrarian parties" 90.parfam "- Ethnic and regional parties" 95.parfam "- Special issue parties" election_date_days_from_prev "Election period (length)" _cons "Constant") // 

**# - Controlling for policy document
use "analysis twosimple.dta", replace

local t = `t' + 1

eststo model1_`t'_5: reg sh_i_commitment c.PositionLogWOzeroDistanceCl i.progtype i.issue_num
tab country_num if e(sample)==1
estadd scalar n_countries = r(r)
estadd local country_dummies = "No"
estadd local year_dummies = "No"
estadd local issue_dummies = "Yes"

eststo model1_`t'_6: reg sh_i_commitment c.PositionLogWOzeroDistanceCl i.progtype i.issue_num i.year i.country_num
tab country_num if e(sample)==1
estadd scalar n_countries = r(r)
estadd local country_dummies = "Yes"
estadd local year_dummies = "Yes"
estadd local issue_dummies = "Yes"

eststo model1_`t'_7: reg sh_i_commitment c.PositionLogWOzeroDistanceCl p_sentences i.issue_num
tab country_num if e(sample)==1
estadd scalar n_countries = r(r)
estadd local country_dummies = "No"
estadd local year_dummies = "No"
estadd local issue_dummies = "Yes"

eststo model1_`t'_8: reg sh_i_commitment c.PositionLogWOzeroDistanceCl p_sentences i.issue_num i.year i.country_num
tab country_num if e(sample)==1
estadd scalar n_countries = r(r)
estadd local country_dummies = "Yes"
estadd local year_dummies = "Yes"
estadd local issue_dummies = "Yes"

esttab model1_`t'_5 model1_`t'_6 model1_`t'_7 model1_`t'_8 using "table `a'`t' - progtype and no of sentences.rtf" , replace label se stats(N r2 n_countries country_dummies year_dummies issue_dummies, labels(Observations R-squared "Number of countries" "Country dummies included" "Year dummies included" "Issue dummies included")) nonotes  star(† 0.1 * 0.05 ** 0.01 *** 0.001) addnotes("Notes: †<0.1 *p<0.05, **p<0.01, ***p<0.001. Country (in model II and IV), year (in model II and IV), and issue dummies (in all models) are not shown.") varwidth(40) cells(b(star fmt(a2)) se(par fmt(a2))) nonumbers mtitles("I" "II" "III" "IV" "V") collabels(" " "" "" "") interaction(" * ") title("Table `a'`t': Manifesto programme controls")  wide drop(*country_num *year *issue_num) order(PositionLogWOzeroDistanceCl) refcat(1.progtype "Manifesto programme type", nolabel) varlabels(1.progtype "- Programme of a single party" 2.progtype "- Programme of two or more parties" 3.progtype "- Estimate" 4.progtype "- Programme taken from main party of electoral coalition" 5.progtype "- Average of all members of an electoral coalition" 6.progtype "- General programme" 8.progtype "- Party bloc programme" 9.progtype "- Other programme type" 99.progtype "- Missing programme"  p_sentences "Number of quasi-sentences in manifesto" PositionLogWOzeroDistanceCl "Positional distance" _cons "Constant") 

**# - Robust and clustered standard errors
use "analysis twosimple.dta", replace
local t = 6
local a "D"
local t = `t' + 1

eststo model1_`t'_1: reg sh_i_commitment c.PositionLogWOzeroDistanceCl i.issue_num, vce(robust)
tab country_num if e(sample)==1
estadd scalar n_countries = r(r)
estadd local country_dummies = "No"
estadd local year_dummies = "No"
estadd local issue_dummies = "Yes"
eststo model1_`t'_2: reg sh_i_commitment c.PositionLogWOzeroDistanceCl i.issue_num i.year i.country_num, vce(robust)
tab country_num if e(sample)==1
estadd scalar n_countries = r(r)
estadd local country_dummies = "Yes"
estadd local year_dummies = "Yes"
estadd local issue_dummies = "Yes"

eststo model1_`t'_3: reg sh_i_commitment c.PositionLogWOzeroDistanceCl i.issue_num, vce(cluster issue_num)
tab country_num if e(sample)==1
estadd scalar n_countries = r(r)
estadd local country_dummies = "No"
estadd local year_dummies = "No"
estadd local issue_dummies = "Yes"
eststo model1_`t'_4: reg sh_i_commitment c.PositionLogWOzeroDistanceCl i.issue_num i.year i.country_num, vce(cluster issue_num)
tab country_num if e(sample)==1
estadd scalar n_countries = r(r)
estadd local country_dummies = "Yes"
estadd local year_dummies = "Yes"
estadd local issue_dummies = "Yes"

eststo model1_`t'_5: reg sh_i_commitment c.PositionLogWOzeroDistanceCl i.issue_num , vce(cluster pf_common_id)
tab country_num if e(sample)==1
estadd scalar n_countries = r(r)
estadd local country_dummies = "No"
estadd local year_dummies = "No"
estadd local issue_dummies = "Yes"
eststo model1_`t'_6: reg sh_i_commitment c.PositionLogWOzeroDistanceCl i.issue_num i.year i.country_num, vce(cluster pf_common_id)
tab country_num if e(sample)==1
estadd scalar n_countries = r(r)
estadd local country_dummies = "Yes"
estadd local year_dummies = "Yes"
estadd local issue_dummies = "Yes"

esttab model1_`t'_1 model1_`t'_2 model1_`t'_3 model1_`t'_4 model1_`t'_5 model1_`t'_6 using "table `a'`t' - standarderrors.rtf", label se stats(N r2 n_countries country_dummies year_dummies issue_dummies, labels(Observations R-squared "Number of countries" "Country dummies included" "Year dummies included" "Issue dummies included")) nonotes  star(† 0.1 * 0.05 ** 0.01 *** 0.001) addnotes("Notes: †<0.1 *p<0.05, **p<0.01, ***p<0.001. Country dummies (in model II, IV, and VI), year dummies (in model II, IV, and IV), and issue dummies (in all models) are not shown. Robust errors are added in model I and II, standard errors clustered at the issue level are added to model III and IV, and standard errors clustered at the party level are added to model V and VI.") varwidth(40) cells(b(star fmt(a2)) se(par fmt(a2))) nonumbers mtitles("I" "II" "III" "IV" "V" "VI") collabels("" "" "")  replace  order() title("Table `a'`t': Robust standard errors as well as standard errors clustered on issues and parties") refcat(10.parfam "Party family" 13.country "Country" 0.cabinet_party2 "Government status", nolabel) wide drop(*issue_num *year *country_num) varlabels(PositionLogWOzeroDistanceCl "Positional distance" _cons "Constant")

**# - Negative binomial regression
use "analysis twosimple.dta", replace

local t = `t' + 1

eststo model1_`t'_1: nbreg sh_i_commitment c.PositionLogWOzeroDistanceCl i.issue_num, irr
tab country_num if e(sample)==1
estadd scalar n_countries = r(r)
estadd local country_dummies = "No"
estadd local year_dummies = "No"
estadd local issue_dummies = "Yes"

eststo model1_`t'_2: nbreg sh_i_commitment c.PositionLogWOzeroDistanceCl i.issue_num i.year i.country_num, irr
tab country_num if e(sample)==1
estadd scalar n_countries = r(r)
estadd local country_dummies = "Yes"
estadd local year_dummies = "Yes"
estadd local issue_dummies = "Yes"

esttab model1_`t'_1 model1_`t'_2 using "table `a'`t' - nbreg.rtf", eform label se stats(N r2_p n_countries country_dummies year_dummies issue_dummies, labels(Observations "Pseudo-R-squared" "Number of countries" "Country dummies included" "Year dummies included" "Issue dummies included")) nonotes  star(† 0.1 * 0.05 ** 0.01 *** 0.001) addnotes("Notes: †<0.1 *p<0.05, **p<0.01, ***p<0.001. Country dummies (in model II), year dummies (in model II), and issue dummies (in both models) are not shown.") varwidth(40) cells(b(star fmt(a2)) se(par fmt(a2))) nonumbers mtitles("I" "II") collabels(" " "" "")  replace  order() title("Table `a'`t': Negative binomial regression") refcat(10.parfam "Party family" 13.country "Country" 0.cabinet_party2 "Government status", nolabel) wide drop(*issue_num *year *country_num lnalpha) varlabels(PositionLogWOzeroDistanceCl "Positional distance" _cons "Constant")


**# - Including issues that the party avoided
use "analysis twosimple.dta", replace

local t = `t' + 1

eststo model1_`t'_1: reg sh_i_commitment c.PositionLogDistanceCl i.Saliencyornot i.issue_num // Notice: Controlling for saliency or not (active/passive centre position)
tab country_num if e(sample)==1
estadd scalar n_countries = r(r)
estadd local country_dummies = "No"
estadd local year_dummies = "No"
estadd local issue_dummies = "Yes"

eststo model1_`t'_2: reg sh_i_commitment c.PositionLogDistanceCl i.Saliencyornot i.issue_num i.year i.country_num // Notice: Controlling for saliency or not (active/passive centre position)
tab country_num if e(sample)==1
estadd scalar n_countries = r(r)
estadd local country_dummies = "Yes"
estadd local year_dummies = "Yes"
estadd local issue_dummies = "Yes"

esttab model1_`t'_1 model1_`t'_2 using "table `a'`t' - including zero.rtf", replace label se stats(N r2 n_countries country_dummies year_dummies issue_dummies, labels(Observations R-squared "Number of countries" "Country dummies included" "Year dummies included" "Issue dummies included")) nonotes  star(† 0.1 * 0.05 ** 0.01 *** 0.001) addnotes("Notes: †<0.1 *p<0.05, **p<0.01, ***p<0.001. Country dummies (in model II), year dummies (in model II), and issue dummies (in both models) are not shown.") varwidth(40) cells(b(star fmt(a2)) se(par fmt(a2))) nonumbers mtitles("I" "II") collabels(" " "" "" "") interaction(" * ") title("Table `a'`t': Including issues that the party avoided")  wide drop(*issue_num *year *country_num 0.Saliencyornot) order(PositionLogDistanceCl) refcat(0.Saliencyornot "Issue focus", nolabel) varlabels(PositionLogDistanceCl "Positional distance" 1.Saliencyornot "Issue engagement (ref = issue avoidance)" _cons "Constant") // 

**# - Measuring positions on dimensions
use "analysis dim.dta", replace
local t = `t' + 1

eststo model1_`t'_1: reg sh_i_commitment c.PositionLogWOzeroDistanceCl i.issue_num
tab country_num if e(sample)==1
estadd scalar n_countries = r(r)
estadd local country_dummies = "No"
estadd local year_dummies = "No"
estadd local issue_dummies = "Yes"

eststo model1_`t'_2: reg sh_i_commitment c.PositionLogWOzeroDistanceCl i.issue_num i.year i.country_num
tab country_num if e(sample)==1
estadd scalar n_countries = r(r)
estadd local country_dummies = "Yes"
estadd local year_dummies = "Yes"
estadd local issue_dummies = "Yes"

esttab model1_`t'_1 model1_`t'_2 using "table `a'`t' - dimensions.rtf" , replace label se stats(N r2 n_countries country_dummies year_dummies issue_dummies, labels(Observations R-squared "Number of countries" "Country dummies included" "Year dummies included" "Issue dummies included")) nonotes  star(† 0.1 * 0.05 ** 0.01 *** 0.001) addnotes("Notes: †<0.1 *p<0.05, **p<0.01, ***p<0.001. Country (in model II) and year (in model II) dummies are not shown.") varwidth(40) cells(b(star fmt(a2)) se(par fmt(a2))) nonumbers mtitles("I" "II") collabels(" " "" "" "") interaction(" * ") title("Table `a'`t': Issue dimensions")  wide drop(*country_num *year 10.issue_num) order(PositionLogWOzeroDistanceCl 10.issue_num 15.issue_num  year) refcat(10.issue_num "Issue dimension", nolabel) varlabels(PositionLogWOzeroDistanceCl "Positional distance" 15.issue_num "Economic dimension (ref = cultural dimension)" _cons "Constant") // 

su PositionLogWOzeroDistanceCl if e(sample)==1, detail
local rlow: di %5.2f `r(min)'
local rhigh: di %5.2f `r(max)'
di "`rlow'  `rhigh'"
margins, at(PositionLogWOzeroDistanceCl=(`r(min)' (0.2) `r(max)'))
marginsplot, ///
	scheme(s1mono) ///
	xtitle("Positional distance") ytitle("Predicted share of commitments") title("") note("", size(vsmall)) ///
	xscale(range(-0.1 1.5)) recastci(rline) ciopts(lpattern(dash)) recast(line) ///
	yscale(range(4 19)) ylabel(5 "5%" 6 "6%" 7 "7%" 8 "8%" 9 "9%" 10 "10%" 11 "11%" 12 "12%" 13 "13%" 14 "14%" 15 "15%" 16 "16%" 17 "17%" 18 "18%" 19 "19%" 20 "20%", angle(360) grid labsize(small)) ///
	addplot(hist PositionLogWOzeroDistanceCl if PositionLogWOzeroDistanceCl<`rhigh',percent yscale(alt axis(2) range(0 (5) 50)) yaxis(2) below gap(10) legend(off)  xscale(range(-0.1 1.5)) xlabel(`rlow' `""No""distance"" ""' 1.0 " " 2.0 " " 3.0 " " 4.0 " " 5.0 " " 6.0 " " 7.0 " " `rhigh' `""Maximum""distance""', labsize(small)) ytitle("Distribution of                                          ""positional distance                                          ", axis(2) ) ylabel(0 "0%" 5 "5%" 10 "10%" 15 "15%" 20 "20%", nogrid axis(2) angle(360) labsize(small)))
	
graph export "dimensions - marginsplot.png", replace


**# - Party dyads
use "analysis dyads.dta", replace
local t = `t' + 1

encode country, g(country_num)
encode issue, g(issue_num)
g year = floor(date / 100)
eststo model1_`t'_1: reg mean_sh_i_commitment PositionLogWOzeroDistance i.issue_num, cluster(pf_common_id)
tab country_num if e(sample)==1
estadd scalar n_countries = r(r)
estadd local country_dummies = "No"
estadd local year_dummies = "No"
estadd local issue_dummies = "Yes"

eststo model1_`t'_2: reg mean_sh_i_commitment PositionLogWOzeroDistance i.issue_num i.year i.country_num, cluster(pf_common_id)
tab country_num if e(sample)==1
estadd scalar n_countries = r(r)
estadd local country_dummies = "Yes"
estadd local year_dummies = "Yes"
estadd local issue_dummies = "Yes"

esttab model1_`t'_1 model1_`t'_2 using "table `a'`t' - dyads.rtf" , replace label se stats(N r2 n_countries country_dummies year_dummies issue_dummies, labels(Observations R-squared "Number of countries" "Country dummies included" "Year dummies included" "Issue dummies included")) nonotes  star(† 0.1 * 0.05 ** 0.01 *** 0.001) addnotes("Notes: †<0.1 *p<0.05, **p<0.01, ***p<0.001. Country (in model II), year (in model II), and issue dummies (in both models) are not shown. Standard errors clustered at the party level. The dependent variable is the mean share of commitments between the two parties within the dyad.") varwidth(40) cells(b(star fmt(a2)) se(par fmt(a2))) nonumbers mtitles("I" "II") collabels(" " "" "" "") interaction(" * ") title("Table `a'`t': Party dyads")  wide drop(*country_num *year *issue_num) order(PositionLogWOzeroDistance year) refcat(, nolabel) varlabels(PositionLogWOzeroDistance "Positional distance" _cons "Constant") 

**# - Lagged distance variable
use "analysis twosimple.dta", replace
local t = `t' + 1

eststo model1_`t'_1: reg sh_i_commitment c.LPositionLogWOzeroDistanceCl i.issue_num
tab country_num if e(sample)==1
estadd scalar n_countries = r(r)
estadd local country_dummies = "No"
estadd local year_dummies = "No"
estadd local issue_dummies = "Yes"

eststo model1_`t'_2: reg sh_i_commitment c.LPositionLogWOzeroDistanceCl i.issue_num i.year i.country_num
tab country_num if e(sample)==1
estadd scalar n_countries = r(r)
estadd local country_dummies = "Yes"
estadd local year_dummies = "Yes"
estadd local issue_dummies = "Yes"

esttab model1_`t'_1 model1_`t'_2 using "table `a'`t' - lagged.rtf" , replace label se stats(N r2 n_countries country_dummies year_dummies issue_dummies, labels(Observations R-squared "Number of countries" "Country dummies included" "Year dummies included" "Issue dummies included")) nonotes  star(† 0.1 * 0.05 ** 0.01 *** 0.001) addnotes("Notes: †<0.1 *p<0.05, **p<0.01, ***p<0.001. Country (in model II), year (in model II), and issue dummies (in both models) are not shown.") varwidth(40) cells(b(star fmt(a2)) se(par fmt(a2))) nonumbers mtitles("I" "II") collabels(" " "" "" "") interaction(" * ") title("Table `a'`t': Positional distance (at previous available election)")  wide drop(*country_num *year *issue_num) order(LPositionLogWOzeroDistanceCl) refcat(, nolabel) varlabels(LPositionLogWOzeroDistanceCl "Positional distance (previous available election)" _cons "Constant") 

**# - Multilevel model
use "analysis twosimple.dta", replace
local t = `t' + 1
	
eststo model1_9_1: mixed sh_i_commitment c.PositionLogWOzeroDistanceCl i.issue_num /// 
	|| country_num: PositionLogWOzeroDistanceCl, covariance(unstructured)  ///
	|| edate: PositionLogWOzeroDistanceCl, covariance(unstructured) ///
	|| pf_common_id: PositionLogWOzeroDistanceCl, covariance(unstructured)
	estat ic // Notice: AIC/BIC becomes smaller (compared to model a and model b above) = suggests that the model fit becomes better!
	tab country_num if e(sample)==1
	estadd scalar n_countries = r(r)
	estadd local issue_dummies = "Yes"

esttab model1_9_1 using "table `a'`t' - multilevel.rtf" , replace label se scalars(ll chi2) stats(N  n_countries issue_dummies, labels(Observations "Number of countries" "Issue dummies included")) nonotes  star(† 0.1 * 0.05 ** 0.01 *** 0.001) addnotes("Notes: †<0.1 *p<0.05, **p<0.01, ***p<0.001. Issue dummies are not shown. Based on multilevel modelling (mixed-effects model) with three levels in the following order (country, election, party), random slopes for positional distance on each level, and with unstructured covariance for each level.") varwidth(40) cells(b(star fmt(a2)) se(par fmt(a2))) nonumbers mtitles("I" "II") collabels(" " "" "" "") interaction(" * ") title("Table `a'`t': Multilevel model")  wide drop(_cons *issue_num) order(PositionLogWOzeroDistanceCl) refcat(, nolabel) varlabels(PositionLogWOzeroDistanceCl "Positional distance" _cons "Constant") //  OBS: ADD CONSTANT MANUALLY TO TABLE!
	
**# - Influential outlier observations 
use "analysis twosimple.dta", replace
local t = `t' + 1

reg sh_i_commitment c.PositionLogWOzeroDistanceCl i.issue_num
predict residuals, resid
scatter residuals PositionLogWOzeroDistanceCl if e(sample),  msymbol(circle)

gen abs_residuals1 = abs(residuals)

summ abs_residuals1, detail
gen is_outlier1a = abs_residuals1 > r(p95) // Exclude top 5% of residuals

summ abs_residuals1, detail
gen is_outlier1b = abs_residuals1 > r(p90) // Exclude top 10% of residuals

summ abs_residuals1, detail
gen is_outlier1c = abs_residuals1 > r(p75) // Exclude top 25% of residuals

reg sh_i_commitment c.PositionLogWOzeroDistanceCl i.issue_num i.year i.country_num
predict residuals2, resid
scatter residuals2 PositionLogWOzeroDistanceCl if e(sample),  msymbol(circle)

gen abs_residuals2 = abs(residuals)

summ abs_residuals2, detail
gen is_outlier2a = abs_residuals2 > r(p95) // Exclude top 5% of residuals

summ abs_residuals2, detail
gen is_outlier2b = abs_residuals2 > r(p90) // Exclude top 10% of residuals

summ abs_residuals2, detail
gen is_outlier2c = abs_residuals2 > r(p75) // Exclude top 25% of residuals

eststo model1_`t'_1: reg sh_i_commitment c.PositionLogWOzeroDistanceCl i.issue_num if !is_outlier1a
tab country_num if e(sample)==1
estadd scalar n_countries = r(r)
estadd local country_dummies = "No"
estadd local year_dummies = "No"
estadd local issue_dummies = "Yes"

eststo model1_`t'_2: reg sh_i_commitment c.PositionLogWOzeroDistanceCl i.issue_num i.year i.country_num if !is_outlier2a
tab country_num if e(sample)==1
estadd scalar n_countries = r(r)
estadd local country_dummies = "Yes"
estadd local year_dummies = "Yes"
estadd local issue_dummies = "Yes"

eststo model1_`t'_3: reg sh_i_commitment c.PositionLogWOzeroDistanceCl i.issue_num if !is_outlier1b
tab country_num if e(sample)==1
estadd scalar n_countries = r(r)
estadd local country_dummies = "No"
estadd local year_dummies = "No"
estadd local issue_dummies = "Yes"

eststo model1_`t'_4: reg sh_i_commitment c.PositionLogWOzeroDistanceCl i.issue_num i.year i.country_num if !is_outlier2b
tab country_num if e(sample)==1
estadd scalar n_countries = r(r)
estadd local country_dummies = "Yes"
estadd local year_dummies = "Yes"
estadd local issue_dummies = "Yes"

eststo model1_`t'_5: reg sh_i_commitment c.PositionLogWOzeroDistanceCl i.issue_num if !is_outlier1c
tab country_num if e(sample)==1
estadd scalar n_countries = r(r)
estadd local country_dummies = "No"
estadd local year_dummies = "No"
estadd local issue_dummies = "Yes"

eststo model1_`t'_6: reg sh_i_commitment c.PositionLogWOzeroDistanceCl i.issue_num i.year i.country_num if !is_outlier2c
tab country_num if e(sample)==1
estadd scalar n_countries = r(r)
estadd local country_dummies = "Yes"
estadd local year_dummies = "Yes"
estadd local issue_dummies = "Yes"

esttab model1_`t'_1 model1_`t'_2 model1_`t'_3 model1_`t'_4 model1_`t'_5 model1_`t'_6 using "table `a'`t' - residuals.rtf",  replace ///
	label se stats(N r2 n_countries country_dummies year_dummies issue_dummies, labels(Observations R-squared "Number of countries" "Country dummies included" "Year dummies included" "Issue dummies included")) nonotes star(† 0.1 * 0.05 ** 0.01 *** 0.001) addnotes("Notes: †<0.1 *p<0.05, **p<0.01, ***p<0.001. Country dummies (included in model II, IV, and VI), year dummies (included in model II, IV, and VI), and issue dummies (included in all models) are not shown. Model I and II exclude top 5 % of the residuals, model III and IV exclude top 10 % of the residuals, and model V and VI exclude top 25 % of the residuals.") varwidth(40) cells(b(star fmt(a2)) se(par fmt(a2))) nonumbers mtitles("I" "II" "III" "IV" "V" "VI") collabels(" " "" "" "") interaction(" * ") title("Table `a'`t': The effect of positional distance on share of commitments (excluding potential outliers)")  wide ///
	drop(*issue_num *country_num *year) ///
	order(PositionLogWOzeroDistanceCl ) ///
	refcat(, label(" ")) ///
	varlabels(PositionLogWOzeroDistanceCl "Positional distance" 1.parl "Parliamentary system (ref = presidential, semi-presidential or hybrid system)" 1.parl#c.PositionLogWOzeroDistanceCl "Positional Distance * Parliamentary system (ref = presidential, semi-presidential or hybrid system)" 1.cabinet_party_simple "Government party (ref = opposition party)" 1.cabinet_party_simple#c.PositionLogWOzeroDistanceCl "Positional distance * Government party (ref = opposition party)" c.PositionLogWOzeroDistanceCl#c.PositionLogWOzeroAbs "Positional distance * Positional extremity" PositionLogWOzeroAbs "Positional extremity" _cons "Constant") // 
	

**# - Splitting up government and opposition
use "analysis twosimple.dta", replace

local t = `t' + 1

eststo model1_`t'_1: reg sh_i_commitment c.PositionLogWOzeroDistanceCl i.issue_num if cabinet_party_simple==0
tab country_num if e(sample)==1
estadd scalar n_countries = r(r)
estadd local country_dummies = "No"
estadd local year_dummies = "No"
estadd local issue_dummies = "Yes"

eststo model1_`t'_2: reg sh_i_commitment c.PositionLogWOzeroDistanceCl i.issue_num i.year i.country_num if cabinet_party_simple==0
tab country_num if e(sample)==1
estadd scalar n_countries = r(r)
estadd local country_dummies = "Yes"
estadd local year_dummies = "Yes"
estadd local issue_dummies = "Yes"

eststo model1_`t'_3: reg sh_i_commitment c.PositionLogWOzeroDistanceCl i.issue_num if cabinet_party_simple==1
tab country_num if e(sample)==1
estadd scalar n_countries = r(r)
estadd local country_dummies = "No"
estadd local year_dummies = "No"
estadd local issue_dummies = "Yes"

eststo model1_`t'_4: reg sh_i_commitment c.PositionLogWOzeroDistanceCl i.issue_num i.year i.country_num if cabinet_party_simple==1
tab country_num if e(sample)==1
estadd scalar n_countries = r(r)
estadd local country_dummies = "Yes"
estadd local year_dummies = "Yes"
estadd local issue_dummies = "Yes"

esttab model1_`t'_1 model1_`t'_2 model1_`t'_3 model1_`t'_4 using "table `a'`t' - gov opp split.rtf",  replace ///
	label se stats(N r2 n_countries country_dummies year_dummies issue_dummies, labels(Observations R-squared "Number of countries" "Country dummies included" "Year dummies included" "Issue dummies included")) nonotes star(† 0.1 * 0.05 ** 0.01 *** 0.001) addnotes("Notes: †<0.1 *p<0.05, **p<0.01, ***p<0.001. Country dummies (included in model II and IV), year dummies (included in model II and IV), and issue dummies (included in all models) are not shown. Model I and II include only opposition parties, while model III and IV include only government parties.") varwidth(40) cells(b(star fmt(a2)) se(par fmt(a2))) nonumbers mtitles("I" "II" "III" "IV" "V" "VI") collabels(" " "" "" "") interaction(" * ") title("Table `a'`t': The effect of positional distance on share of commitments (splitting government and opposition parties)")  wide ///
	drop(*issue_num *country_num *year) ///
	order(PositionLogWOzeroDistanceCl) ///
	refcat(, label(" ")) ///
	varlabels(PositionLogWOzeroDistanceCl "Positional distance" 1.parl "Parliamentary system (ref = presidential, semi-presidential or hybrid system)" 1.parl#c.PositionLogWOzeroDistanceCl "Positional Distance * Parliamentary system (ref = presidential, semi-presidential or hybrid system)" 1.cabinet_party_simple "Government party (ref = opposition party)" 1.cabinet_party_simple#c.PositionLogWOzeroDistanceCl "Positional distance * Government party (ref = opposition party)" c.PositionLogWOzeroDistanceCl#c.PositionLogWOzeroAbs "Positional distance * Positional extremity" PositionLogWOzeroAbs "Positional extremity" _cons "Constant") // 

**# - Using pledge data to measure dependent variable 
use "AJPS_CPPG_pledges_10April2017.dta", clear  // Can be found on Harvard Dataverse: https://doi.org/10.7910/DVN/YJUIBI

g countryname = ""
replace countryname = "United States" if country==1
replace countryname = "United Kingdom" if country==2
replace countryname = "Netherlands" if country==3
replace countryname = "Ireland" if country==4
replace countryname = "Sweden" if country==5
replace countryname = "Spain" if country==6
replace countryname = "Germany" if country==7
replace countryname = "Italy" if country==8
replace countryname = "Portugal" if country==9
replace countryname = "Bulgaria" if country==10
replace countryname = "Canada" if country==11
replace countryname = "Austria" if country==12

rename (country countryname) (country_num country)

g partyname = "" 
g partyfacts_id = .

*US
replace partyname = "Republican Party" if partyid == 101
replace partyfacts_id = 809 if partyid == 101
replace partyname = "Democratic Party" if partyid == 102
replace partyfacts_id = 432 if partyid == 102

*UK
replace partyname = "Conservative Party" if partyid == 201
replace partyfacts_id = 1567 if partyid == 201
replace partyname = "Labour Party" if partyid == 202
replace partyfacts_id = 1516 if partyid == 202

*NL
replace partyname = "PvdA" if partyid == 301
replace partyfacts_id = 1234  if partyid == 301
replace partyname = "D66" if partyid == 302
replace partyfacts_id = 45 if partyid == 302
replace partyname = "CDA" if partyid == 303
replace partyfacts_id = 1157 if partyid == 303
replace partyname = "VVD" if partyid == 304
replace partyfacts_id = 828 if partyid == 304

*IE
replace partyname = "FF" if partyid == 401
replace partyfacts_id = 1055 if partyid == 401
replace partyname = "FG" if partyid == 402
replace partyfacts_id = 1288 if partyid == 402
replace partyname = "Labour" if partyid == 403
replace partyfacts_id = 562 if partyid == 403
replace partyname = "PD" if partyid == 404
replace partyfacts_id = 924 if partyid == 404
replace partyname = "Workers Party" if partyid == 405
replace partyfacts_id = 208 if partyid == 405
replace partyname = "DL" if partyid == 406
replace partyfacts_id = 1172 if partyid == 406
replace partyname = "National Coalition" if partyid == 407
replace partyname = "Green" if partyid == 408
replace partyfacts_id = 1775 if partyid == 408
replace partyname = "SF" if partyid == 409
replace partyfacts_id = 4 if partyid == 409

*SE
replace partyname = "Vensterpartiet" if partyid == 501
replace partyfacts_id = 830 if partyid == 501
replace partyname = "Socialdemokraterna" if partyid == 502
replace partyfacts_id = 487 if partyid == 502
replace partyname = "Centerpartiet" if partyid == 503
replace partyfacts_id = 199 if partyid == 503
replace partyname = "Folkpartiet" if partyid == 504 
replace partyfacts_id = 1274 if partyid == 504
replace partyname = "Moderaterna" if partyid == 505
replace partyfacts_id = 690 if partyid == 505
replace partyname = "Kristdemokraterna" if partyid == 506
replace partyfacts_id = 651 if partyid == 506
replace partyname = "Miljøpartiet" if partyid == 507
replace partyfacts_id = 456 if partyid == 507
replace partyname = "Ny demokrati" if partyid == 508
replace partyfacts_id = 343 if partyid == 508
replace partyname = "Sverigedemokraterna" if partyid == 509
replace partyfacts_id = 409 if partyid == 509
replace partyname = "Allians for Sverige " if partyid == 510
replace partyname = "Rødgrøna" if partyid == 511

*ES
replace partyname = "PP" if partyid == 601
replace partyfacts_id = 441 if partyid == 601
replace partyname = "PSOE" if partyid == 602
replace partyfacts_id = 1338 if partyid == 602
replace partyname = "CiU" if partyid == 603
replace partyfacts_id = 139 if partyid == 603

*DE
replace partyname = "SPD" if partyid == 701
replace partyfacts_id = 383 if partyid == 701
replace partyname = "CDU/CSU" if partyid == 702
replace partyfacts_id = 211 if partyid == 702
replace partyname = "FDP" if partyid == 703
replace partyfacts_id = 573 if partyid == 703
replace partyname = "Green" if partyid == 704
replace partyfacts_id = 1816 if partyid == 704
replace partyname = "Linke" if partyid == 705
replace partyfacts_id = 1545 if partyid == 705

*IT
replace partyname = "Prodi I's Ulivo coalition (PDS/PPI/RI/FdV/UD)" if partyid == 801 & year<2000
replace partyname = "Prodi II's coalition Unione (DS/DL/PRC/RnPPdCI/IdV/FdV/UDEUR)" if partyid == 801 & year>2000
replace partyfacts_id = 1372 if partyid == 801
replace partyname = "Berlusconi/Right" if partyid == 802
replace partyfacts_id = 365 if partyid == 802 & year == 2008
replace partyfacts_id = 1626 if partyid == 802 & year == 2001

*PT
replace partyname = "PS" if partyid == 901
replace partyfacts_id = 655 if partyid == 901
replace partyname = "PSD" if partyid == 902
replace partyfacts_id = 1359 if partyid == 902
replace partyname = "CDS_PP" if partyid == 903
replace partyfacts_id = 1308 if partyid == 903
replace partyname = "CDU" if partyid == 904
replace partyfacts_id = 284 if partyid == 904
replace partyname = "BE" if partyid == 905
replace partyfacts_id = 1310 if partyid == 905

*BG
replace partyname = "Ataka" if partyid == 1001
replace partyfacts_id = 1793 if partyid == 1001
replace partyname = "BBB" if partyid == 1002
replace partyfacts_id = 1027 if partyid == 1002
replace partyname = "BNS" if partyid == 1003
replace partyfacts_id = 263 if partyid == 1003
replace partyname = "BSP" if partyid == 1004
replace partyfacts_id = 1665 if partyid == 1004
replace partyname = "BZNS" if partyid == 1005
replace partyfacts_id = 2060 if partyid == 1005
replace partyname = "DPS" if partyid == 1006
replace partyfacts_id = 982 if partyid == 1006
replace partyname = "DSB" if partyid == 1007
replace partyfacts_id = 1195 if partyid == 1007
replace partyname = "EuroLeft" if partyid == 1008
replace partyfacts_id = 149 if partyid == 1008
replace partyname = "NDSV" if partyid == 1009
replace partyfacts_id = 374 if partyid == 1009
replace partyname = "ODS" if partyid == 1010
replace partyfacts_id = 1183 if partyid == 1010 
replace partyname = "ONS" if partyid == 1011
replace partyfacts_id = 1765 if partyid == 1011
replace partyname = "NS" if partyid == 1012
replace partyfacts_id = 747 if partyid == 1012
replace partyname = "UDF/SDS" if partyid == 1013
replace partyfacts_id = 482 if partyid == 1013
replace partyname = "GERB" if partyid == 1014
replace partyfacts_id = 760 if partyid == 1014
replace partyname = "SK" if partyid == 1015
replace partyfacts_id = 58 if partyid == 1015

*CA
replace partyname = "Canadian Alliance" if partyid == 1101
replace partyfacts_id = 1332 if partyid == 1101
replace partyname = "Bloc QuŽbŽcois" if partyid == 1102
replace partyfacts_id = 1428 if partyid == 1102
replace partyname = "Conservative Party of Canada" if partyid == 1103
replace partyfacts_id = 1004 if partyid == 1103
replace partyname = "Liberal Party of Canada" if partyid == 1104
replace partyfacts_id = 1739 if partyid == 1104
replace partyname = "New Democratic Party" if partyid == 1105
replace partyfacts_id = 152 if partyid == 1105
replace partyname = "Progressive Conservative Party of Canada" if partyid == 1106
replace partyfacts_id = 232 if partyid == 1106
replace partyname = "Reform Party of Canada" if partyid == 1107
replace partyfacts_id = 1757 if partyid == 1107

*AT
replace partyname = "OVP" if partyid == 1201
replace partyfacts_id = 1329 if partyid == 1201
replace partyname = "FPO" if partyid == 1202
replace partyfacts_id = 463 if partyid == 1202
replace partyname = "SPO" if partyid == 1203
replace partyfacts_id = 1384 if partyid == 1203
replace partyname = "BZO" if partyid == 1204
replace partyfacts_id = 599 if partyid == 1204
replace partyname = "GRUNE" if partyid == 1205 
replace partyfacts_id = 1659 if partyid == 1205

g pf_common_id = partyfacts_id

g ecopledge_pos = typexpand + typtaxincr - typcut - typtaxcut
g ecopledge_num = typexpand + typtaxincr + typcut + typtaxcut
g pledge_num = 1

collapse (sum) ecopledge* pledge_num, by(country pf_common_id year)

g ecopledge_rel = ecopledge_num/pledge_num*100

merge 1:m country pf_common_id year using "analysis dim.dta", gen(CMP_pledge)

drop country_num 
encode country, g(country_num)

local t = `t' + 1

eststo model1_`t'_1: reg ecopledge_num c.PositionLogWOzeroDistanceCl i.year i.country_num if issue=="Economic dimension"
tab country_num if e(sample)==1
estadd scalar n_countries = r(r)
estadd local country_dummies = "Yes"
estadd local year_dummies = "Yes"
estadd local issue_dummies = "No"

eststo model1_`t'_2: reg ecopledge_num c.PositionLogWOzeroDistanceCl i.year i.country_num if issue=="Cultural dimension"
tab country_num if e(sample)==1
estadd scalar n_countries = r(r)
estadd local country_dummies = "Yes"
estadd local year_dummies = "Yes"
estadd local issue_dummies = "No"

esttab model1_`t'_1 model1_`t'_2  using "table `a'`t' - pledge data.rtf", replace label se stats(N r2 n_countries country_dummies year_dummies issue_dummies, labels(Observations R-squared "Number of countries" "Country dummies included" "Year dummies included" "Issue dummies included")) nonotes  star(† 0.1 * 0.05 ** 0.01 *** 0.001) addnotes("Notes: †<0.1 *p<0.05, **p<0.01, ***p<0.001. Country dummies and year dummies are not shown. Model I shows positional distance on the economic dimension, while model II shows positional distance on the cultural dimension. ") varwidth(40) cells(b(star fmt(a2)) se(par fmt(a2))) nonumbers mtitles("I" "II") collabels(" " "" "" "") interaction(" * ") title("Table `a'`t': Using the number of economic election pledges as dependent variable")  wide drop( *year *country_num) order(PositionLogWOzeroDistanceCl year) refcat() varlabels(PositionLogWOzeroDistanceCl "Positional distance" _cons "Constant") // 

	
**# Hold-one-out analysis (JACK-KNIFE APPROACH)
use "after analysis.dta", replace

local t = `t' + 1

**# - Jack-knife approach with country
levelsof country_num if esample2==1, local(cn)
local a ""
foreach c of local cn {
	eststo model1_`t'_1_`c': reg sh_i_commitment c.PositionLogWOzeroDistanceCl i.issue_num i.year i.country_num if country_num!=`c'
    local name : label country_num `c'
	local a "`a' `name'"
	*eststo model_`c'

}
di "`a'"

coefplot model1_`t'_1_*, keep(PositionLogWOzeroDistanceCl) ///
    xline(0, lcolor(black)) xtitle(" " " ""The effect of positional distance on the share of commitments") ///
    ytitle("Coefficient for positional distance") ///
	ytitle(" ") legend(label(2 "Excluding Australia") label(4 "Excluding Austria") label(6 "Excluding Belgium") label(8 "Excluding Bulgaria") label(10 "Excluding Canada") label(12 "Excluding Croatia") label(14 "Excluding Czech Republic") label(16 "Excluding Denmark") label(18 "Excluding Estonia") label(20 "Excluding Finland") label(22 "Excluding France") label(24 "Excluding Germany") label(26 "Excluding Greece") label(28 "Excluding Hungary") label(30 "Excluding Iceland") label(32 "Excluding Ireland") label(34 "Excluding Latvia") label(36 "Excluding Lithuania") label(38 "Excluding Luxembourg") label(40 "Excluding Netherlands") label(42 "Excluding New Zealand") label(44 "Excluding Norway") label(46 "Excluding Poland") label(48 "Excluding Portugal") label(50 "Excluding Romania") label(52 "Excluding Slovakia") label(54 "Excluding Slovenia") label(56 "Excluding Spain") label(58 "Excluding Sweden") label(60 "Excluding Switzerland") label(62 "Excluding United Kingdom") label(64 "Excluding United States") size(small)) ylabel(1 " ", notick) xscale(range(-2 0.1)) xlabel(-2 (0.5) 0)
	graph export "jack-knife country.png", replace

**# - Jack-knife approach with effective number of parties
use "after analysis.dta", replace

eststo clear

gen effpar_leg_cat = .
replace effpar_leg_cat = 1 if effpar_leg >= 0 & effpar_leg <= 2
replace effpar_leg_cat = 2 if effpar_leg > 2 & effpar_leg <= 4
replace effpar_leg_cat = 3 if effpar_leg > 4 & effpar_leg <= 6
replace effpar_leg_cat = 4 if effpar_leg > 6 & effpar_leg <= 8
replace effpar_leg_cat = 5 if effpar_leg > 8 & effpar_leg <= 10
replace effpar_leg_cat = 6 if effpar_leg > 10 & effpar_leg <= 12


levelsof effpar_leg_cat if esample2==1, local(ep)
local a ""
foreach e of local ep {
	eststo model1_`t'_2_`e': reg sh_i_commitment c.PositionLogWOzeroDistanceCl i.issue_num i.year i.country_num if effpar_leg_cat!=`e'

}
di "`a'"

coefplot model1_`t'_2_*, keep(PositionLogWOzeroDistanceCl) ///
    xline(0, lcolor(black)) xtitle(" " " ""The effect of positional distance on the share of commitments") ///
    ytitle("Coefficient for positional distance") ///
	ytitle(" ") legend(label(2 "Excluding systems with two or fewer ENP") label(4 "Excluding systems with more than two and fewer than four ENP") label(6 "Excluding systems with more than four and fewer than six ENP") label(8 "Excluding systems with more than six and fewer than eight ENP") label(10 "Excluding systems with more than eight and fewer than ten ENP") label(12 "Excluding systems with more than ten and fewer than twelve ENP") size(vsmall)) ylabel(1 " ", notick) xscale(range(-2 0.1)) xlabel(-2 (0.5) 0)
graph export "jack-knife effective number of parties.png", replace


**# - Jack-knife approach with party family 
eststo clear
use "after analysis.dta", clear

levelsof parfam if esample2==1 & parfam!=999, local(pa)
local a ""
foreach p of local pa {
	eststo model1_`t'_3_`p': reg sh_i_commitment c.PositionLogWOzeroDistanceCl i.issue_num i.year i.country_num if parfam!=`p'
    local name : label parfam `p'
	local a "`a' `name'"
	*eststo model_`c'

}
di "`a'"

coefplot model1_`t'_3_*, keep(PositionLogWOzeroDistanceCl) ///
    xline(0, lcolor(black)) xtitle(" " " ""The effect of positional distance on the share of commitments") ///
    ytitle("Coefficient for positional distance") ///
	ytitle(" ") legend(label(2 "Excluding Ecological parties") label(4 "Excluding Socialist or other left parties") label(6 "Excluding Social democratic parties") label(8 "Excluding Liberal parties") label(10 "Excluding Christian democratic parties") label(12 "Excluding Conservative parties") label(14 "Excluding Nationalist parties") label(16 "Excluding Agrarian parties") label(18 "Excluding Ethnic and regional parties") label(20 "Excluding Special issue parties") label(22 "Excluding Electoral alliance") size(small)) ylabel(1 " ", notick) xscale(range(-2 0.1)) xlabel(-2 (0.5) 0)
graph export "jack-knife parfam.png", replace


	
**# MODEL ASSUMPTIONS
*Lowess curve 
use "after analysis.dta", replace

lowess sh_i_commitment PositionLogWOzeroDistanceCl if esample2==1, scheme(s1mono) msize(vtiny) note(" ") ytitle("Share of commitments (in %)") xtitle(" ""Positional distance") xlabel(0 (1) 8) ylabel(0 (10) 100, angle(360)) title(" ")
graph export "lowess.png", replace


**# DESCRIPTIVES
**# - Distribution of positional distance
use "after analysis.dta", replace

graph bar PositionLogWOzeroDistanceCl if parfam!=98 & esample2==1, scheme(s1mono) over(parfam, sort(1) relabel(1 "Ecological parties" 2 "Socialist or other left parties" 3 "Social democratic parties" 4 "Liberal parties" 5 "Christian democratic parties" 6 "Conservative parties" 7 "Nationalist parties" 8 "Agrarian parties" 9 "Ethnic and regional parties" 10 "Special issue parties" 11 "Electoral alliance") label(labsize(small) angle(45))) ytitle("Positional distance""(mean across party families)" " ") // sort(1) 
graph export "descriptive - PositionLogWOzeroDistanceCl - parfam.png", replace


graph bar PositionLogWOzeroDistanceCl if esample2==1, scheme(s1mono) over(issue_num, sort(1) label(angle(45))) ytitle("Positional distance""(mean across issues)" " ") // sort(1) 
graph export "descriptive - PositionLogWOzeroDistanceCl - issue.png", replace

graph bar PositionLogWOzeroDistanceCl if esample2==1, scheme(s1mono) over(country_num, sort(1) label(labsize(small) angle(45))) ytitle("Positional distance""(mean across countries)"" ") // sort(1) 
graph export "descriptive - PositionLogWOzeroDistanceCl - country_num.png", replace

use "after analysis.dta", replace
keep if esample2==1
collapse (mean) PositionLogWOzeroDistanceCl, by(year)
tw connected PositionLogWOzeroDistanceCl year, note(" ") xtitle("Year") scheme(s1mono) ytitle("Positional distance""(mean across years)"" ") // sort(1) 
graph export "descriptive - PositionLogWOzeroDistanceCl - time.png", replace

**# - Distribution of commitments across different variables
use "after analysis.dta", replace

graph bar sh_i_commitment if parfam!=98 & esample2==1, scheme(s1mono) over(parfam, sort(1) relabel(1 "Ecological parties" 2 "Socialist or other left parties" 3 "Social democratic parties" 4 "Liberal parties" 5 "Christian democratic parties" 6 "Conservative parties" 7 "Nationalist parties" 8 "Agrarian parties" 9 "Ethnic and regional parties" 10 "Special issue parties" 11 "Electoral alliance") label(labsize(small) angle(45))) ytitle("Share of commitments""(mean across party families)" " ")
graph export "descriptive sh_i_commitment - parfam.png", replace

bys issue_num: su sh_i_commitment if esample2==1
graph bar sh_i_commitment if esample2==1, scheme(s1mono) over(issue_num, sort(1) label(angle(45))) ytitle("Share of commitments""(mean across issues)" " ") // sort(1) 
graph export "descriptive - sh_i_commitment - issue.png", width(6000) height(4000)  replace
graph export "descriptive_sh_i_commitment_issue.eps", as(eps) replace


bys country_num: su sh_i_commitment if esample2==1
graph bar sh_i_commitment if esample2==1, scheme(s1mono) over(country_num, sort(1) label(labsize(small) angle(45))) ytitle("Share of commitments""(mean across countries)"" ") // sort(1) 
graph export "descriptive - sh_i_commitment - country_num.png", width(6000) height(4000) replace
graph export "descriptive - sh_i_commitment - country_num.eps", as(eps) replace

use "after analysis.dta", replace
keep if esample2==1
collapse (mean) sh_i_commitment, by(year)
lowess sh_i_commitment year, scheme(s1mono) ytitle("Share of commitments""(mean across years)"" ") note(" ") xtitle(" " "Year") title(" ") // sort(1) 
graph export "descriptive - sh_i_commitment - time.png", replace

**# - Number of sentences coded, number of election programmes, included issues, and included manifestos
use "after analysis.dta", replace

egen totalsentencesall = total(sentences) if esample2==0
egen totalsentences = total(sentences) if esample2==1
tab totalsentences
tab totalsentencesall

egen electionprogram = tag(country pf_common_id date) if esample2==1
tab electionprogram

bysort electionprogram country (date partyname): g num1 = _n
bysort electionprogram country date (partyname): g num2 = _n
sort electionprogram country date partyname
g country2 = country
replace country = "" if num1!=1
tostring date, replace
gen date3 = substr(date, 1, 4) + "-" + substr(date, 5, 2)
replace date = "" if num2!=1
browse country partyname date num1 num2  if electionprogram==1
keep if electionprogram==1
rename (country date partyname) (Country Election Party)
order Country Election Party
keep Country Election Party

export excel using "manifestoes included.xlsx", replace firstrow(variables)



